package com.xuecheng.content.controller;

import com.xuecheng.api.contant.CourseAuditApi;
import com.xuecheng.api.contant.model.dto.CourseBaseDTO;
import com.xuecheng.api.contant.model.qo.QueryCourseBaseModel;
import com.xuecheng.api.contant.model.vo.CourseAuditVO;
import com.xuecheng.common.domain.page.PageRequestParams;
import com.xuecheng.common.domain.page.PageVO;
import com.xuecheng.content.common.constant.ContentErrorCode;
import com.xuecheng.content.convert.CourseBaseConvert;
import com.xuecheng.content.service.CourseBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class CourseAuditController implements CourseAuditApi {

    // 运营平台标识--可以查询所哟教学机构的数据

    @Autowired
    private CourseBaseService courseBaseService;


    /**
     * 课程审核
     * @param auditVO 课程审核时的VO对象
     */
    @PostMapping("m/courseReview/approve")
    public void approveCourse(@RequestBody CourseAuditVO auditVO) {

        CourseBaseDTO dto = CourseBaseConvert.INSTANCE.vo2dto(auditVO);

            courseBaseService.approve(dto);

    }

    /**
     * 课程信息分页条件查询实现-运营
     * @param params PageRequestParams 分页封装数据
     * @param model QueryCourseBaseModel 条件查询封装数据
     * @return PageVO 分页结果封装数据
     */
    @PostMapping("m/course/list")
    public PageVO<CourseBaseDTO> queryCourseList(PageRequestParams params, @RequestBody QueryCourseBaseModel model) {
        // 平台唯一凭证
        Long operatingTerrace = (long) ContentErrorCode.E_120000.getCode();
        // 调用service层方法
        PageVO<CourseBaseDTO> pageVO = courseBaseService.queryCourseBaseList(params, model,operatingTerrace);
        // 返回数据
        return pageVO;
    }
}